package com.kin207.netty.listener.server.handle;

import java.util.Collection;

import com.kin207.netty.context.RequestContext;
import com.kin207.netty.handle.IMessageHandle;
import com.kin207.netty.listener.server.handle.vo.ServerCloseReqVo;
import com.kin207.netty.server.IServer;
import com.kin207.netty.server.ServerManager;

public class ServerCloseMessageHandle implements IMessageHandle<ServerCloseReqVo> {

	public String name() {
		return "/server/close";
	}

	public Class paramClass() {
		return ServerCloseReqVo.class;
	}

	public void handle(ServerCloseReqVo param) {
		RequestContext req = RequestContext.curr.get();
		
		
//		if(!"".equals(param.getPassword())){
//			req.wirte("error:403");
//		}
		
		ServerManager serverManager = req.getServer().getServerManager();
		IServer server = serverManager.getServer(param.getName());
		if(server!=null){
			server.close();
		}else{
			req.wirte("server:404");
		}
	}

}
